
#include "type.h"
#include "stdio.h"
#include "const.h"
#include "protect.h"
#include "string.h"
#include "fs.h"
#include "proc.h"
#include "tty.h"
#include "console.h"
#include "global.h"
#include "proto.h"

/**
 * @parm pathname 绝对路径+文件名
 * @parm flags O_CREAT(创建), O_RDWR(读取和写入), etc.
 */
PUBLIC int open(const char* pathname, int flags) {
    MESSAGE msg;

    msg.type = OPEN;

    msg.PATHNAME = (void*) pathname;
    msg.FLAGS = flags;
    msg.NAME_LEN = strlen(pathname);

    send_recv(BOTH, TASK_FS, &msg);
    assert(msg.type == SYSCALL_RET);

    return msg.FD;
}

